package com.cb.domain.service.user.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cb.core.dao.GenericDAO;
import com.cb.core.service.impl.GenericManagerImpl;
import com.cb.domain.dao.user.UserDAO;
import com.cb.domain.model.user.UserAccount;
import com.cb.domain.service.user.UserManager;

@Service
public class UserManagerImpl extends GenericManagerImpl<UserAccount, Long> implements UserManager{
	
	@Autowired
	public UserManagerImpl(UserDAO userDAO) {
		super(userDAO);
		// TODO Auto-generated constructor stub
	}

	@Autowired
	private UserDAO userDAO;
	
	public UserAccount findByUserName(String userName){
		return userDAO.findByUserName(userName);
	}

	public List<UserAccount> findByEmail(String email) {
		return userDAO.findByEmail(email);
	}

	public void updateUserStatus(Long userId, String status) {
		UserAccount user = get(userId);
	}

	public void updateUserIcon(Long userId, String icon) {
		UserAccount user = get(userId);
	}

	public void updatePassword(Long userId, String origPassword, String password) {
		UserAccount user = get(userId);
	}

	public Boolean isRegisterEmail(String email) {
		return userDAO.isRegisterEmail(email);
	}

	public Boolean isRegisteredUserName(String userName) {
		return userDAO.isRegisteredUserName(userName);
	}

	@Override
	public UserAccount save(UserAccount object) {
		// TODO Auto-generated method stub
		UserAccount user=super.save(object);
		//写进索引
		//saveIndex.saveIndex(user);
		return user;
	}
	
	public List<UserAccount> getAllUserType(Long type) {
		return userDAO.getAllUserType(type);
	}
	
	public Integer getAllUserCount() {
		// TODO Auto-generated method stub
		return userDAO.getAllUserCount();
	}
	
	public List getAllUserId(){
		return userDAO.getAllUserId();
	}
}
